# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=deepin-pw-check
pkgver=6.0.2
pkgrel=1
pkgdesc='Tool to verify the validity of the password'
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/deepin-pw-check"
license=('GPL3')
depends=('cracklib' 'gtk3' 'iniparser')
makedepends=('deepin-gettext-tools' 'git' 'go')
groups=('deepin')
source=("https://github.com/linuxdeepin/deepin-pw-check/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('64f24f935c4aef35418f10a85f827134d1e5eaa3325dd4dfe60f927f8ea3f0f526c6dce89f1701871839577c315e90fbcdce6e9436a11ed2545f91dfab6087ad')

prepare() {
  cd deepin-pw-check-$pkgver
  sed -i 's|iniparser/||' */*.c
  sed -i 's|gcc |gcc ${CFLAGS} ${LDFLAGS} |;/export GOPATH/d' Makefile
}

build() {
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  export GOPATH="${srcdir}/gopath"

  cd deepin-pw-check-$pkgver
  make
}

package() {
  cd deepin-pw-check-$pkgver
  make DESTDIR="$pkgdir" PKG_FILE_DIR=/usr/lib/pkgconfig PAM_MODULE_DIR=/usr/lib/security install
}
